Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rust, python): Return datetime for mean/median of Date colum #16795

Merged
merged 1 commit into from
Jun 7, 2024

Conversation

mcrumiller
Copy link
Contributor

Old PR was pretty stale, so here is a new one.

Resolves #13598. Part of overall #13599.

This treats dates and datetimes as analagous to integers/floats: the mean of ints is a float, and now the mean of dates is a datetime:

mean(1, 2) = 1.5
mean(2023-01-01, 2023-01-02) = 2023-01-01 12:00.

This is the last temporal mean/median PR, which means a lot of custom logic for the different temporal types has been collapsed/simplified. If this is accepted, we can deprecate dt.mean and dt.median, as mean/median for all temporals have now been implemented, they are now functionally equivalent to series.mean and series.median for all temporal dtypes. I'll do a followup on std/var/quantile.

Note that this breaks streaming date mean/median, and so for the time being I have set it to return a null series. I don't want to hack in a solution since a new streaming engine is being developed, so in the meantime I'm not completely sure what to do.

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars labels Jun 6, 2024
Copy link

codspeed-hq bot commented Jun 6, 2024

CodSpeed Performance Report

Merging #16795 will degrade performances by 16.52%

Comparing mcrumiller:date-mean (1ce4c0b) with main (fd4c71e)

Summary

⚡ 1 improvements
❌ 1 regressions
✅ 35 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main mcrumiller:date-mean Change
test_groupby_h2oai_q5 1.9 ms 2.3 ms -16.52%
test_tpch_q14 2.5 ms 2.1 ms +17.45%

@ritchie46 ritchie46 merged commit faf0f06 into pola-rs:main Jun 7, 2024
26 of 27 checks passed
@mcrumiller mcrumiller deleted the date-mean branch June 7, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mean and median for pl.Date should return a datetime
2 participants